<template>
  <router-link
    tag="div"
    class="today-mood"
    :to="{name:to}"
  >
    <section-title title="今日心情" />
    <div class="mood-tips" v-if="!isEdited">来记录心情吧。</div>
    <div class="mood-wrap" v-if="isEdited">
      <div class="mood-article">{{moodArticle}}</div>
      <div class="mood-icon" :style="{backgroundImage:`url('${icon}')`}"></div>
    </div>
  </router-link>
</template>

<script>
import { createNamespacedHelpers } from 'vuex'
import { SectionTitle } from '@/components'
import { getMoodIcon } from '@/tools'

const { mapState } = createNamespacedHelpers('Mood')
export default {
  name: 'today-mood',
  components: { SectionTitle },
  computed: {
    ...mapState(['isEdited', 'moodCode', 'moodArticle']),
    icon() {
      return getMoodIcon(this.moodCode).iconLong
    },
    to() {
      return this.isEdited ? 'mood-history' : 'mood-edit'
    }
  },
  data: () => ({
    acticle: '来记录心情吧.'
  }),
  methods: {}
}
</script>

<style lang="stylus">
$icon-w = 109px;
$icon-h = 268px;
$scale = 0.5;

.today-mood {
  .mood-tips {
    margin: 20px 0;
    text-align: center;
  }

  .mood-wrap {
    display: flex;
    border-bottom: 1px solid $border-color;
  }

  .mood-article {
    flex: 1;
    align-self: center;
    line-height: 1.5;
    text-align: center;
    font-size: 120%;
  }

  .mood-icon {
    flex: 0 0 auto;
    align-self: flex-end;
    width: $scale * $icon-w;
    height: $scale * $icon-h;
    margin-left: 2em;
    background: center / cover no-repeat;
  }
}
</style>
